﻿@model AesApplication.Models.Store

@{
    ViewBag.Title = "Edit";
}

<h2>Edit</h2>

@using (Html.BeginForm()) {
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Store</legend>

        @Html.HiddenFor(model => model.ID)

        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>
        
        <!-- start stuff added by Nolan -->
        <div class="editor-label">
            @Html.LabelFor(model => model.Departments)
        </div>
        <table>
            @foreach (var dept in Model.Departments)
            {
                <tr>
                    <td>
                        @Html.DisplayFor(_ => dept.Name)
                    </td>
                    <td>
                        @Html.ActionLink("Edit", "Edit", "Department", new { id = dept.ID }, null) |
                        @Html.ActionLink("Delete", "Delete", "Department", new { id = dept.ID }, null)
                    </td>
                </tr>
            }
        </table>
        @Html.ActionLink("Create department", "Create", "Department", new { storeId = Model.ID }, null)
        <!-- end stuff added by Nolan -->

        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
